import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../spaces/filespace/fileSpace.dart';
import '../../helper/routeHelper.dart';
import '../../helper/uidata.dart';

import '../../spaces/report_space/report_list.dart';
import '../../spaces/image_space/record_list.dart';

class KqxcPage extends StatefulWidget {
  @override
  createState() => new KqxcPageState();
}

class KqxcPageState extends State<KqxcPage> {
//  定义底部导航列表
  final List<BottomNavigationBarItem> bottomTabs = [
    new BottomNavigationBarItem(icon: new Icon(Icons.image), label: ('巡查照片')),
    new BottomNavigationBarItem(
        icon: new Icon(Icons.cloud_upload), label: ('相关文件')),
    new BottomNavigationBarItem(icon: new Icon(Icons.list), label: ('巡查记录'))
  ];
  Widget getBody(int i) {
    if (i == 0) return RecordListPage(UIData.KqxcSpaceId, true);
    if (i == 1) return FileSpacePage(UIData.KqxcSpaceId, "库区巡查", true);
    if (i == 2) return ReportListPage(UIData.KqxcSpaceId);
    return new Container();
  }

  int currentIndex = 0; //当前索引
  late Widget currentPage; //当前页面

  @override
  void initState() {
    super.initState();
    currentPage = getBody(0);
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return new Scaffold(
      //floatingActionButton: FloatingActionButton(onPressed:(){ ChannelHelper.showToast("Hello,world!");},),
      appBar: new AppBar(
        // title: bottomTabs[currentIndex].title,
        title: Text("库区巡查"),
        actions: <Widget>[
          ElevatedButton(
            child: Icon(
              Icons.file_download,
              color: Colors.white,
            ),
            onPressed: () {
              RouteHelper.DownloadList(context);
            },
          ),
        ],

        // leading: Icon(Icons.menu),
      ),
      bottomNavigationBar: new BottomNavigationBar(
          type: BottomNavigationBarType.fixed,
          currentIndex: currentIndex,
          items: bottomTabs,
          fixedColor: Colors.blue,
          onTap: (index) {
            setState(() {
              currentIndex = index;
              currentPage = getBody(currentIndex);
            });
          }),
      body: currentPage,
    );
  }
}
